﻿namespace TestApp.DataService
{
    using System;
    using System.Diagnostics.Contracts;
    using System.ServiceModel;

    internal sealed class CallbackProvider<T> : ICallbackProvider<T> where T : class
    {
        public T GetCallback()
        {
            Contract.Requires<InvalidOperationException>(OperationContext.Current != null);
            Contract.Ensures(Contract.Result<T>() != null);

            return OperationContext.Current.GetCallbackChannel<T>();
        }
    }
}
